var newsTable;
function getemailRecordList() {
    getemailRecordcount();
    if (typeof newsTable !== 'undefined') {
        newsTable.fnPageChange('first');
        return;
    }
    var i = 1;
    newsTable = $("#emailRecordList").DataTable({
        "sAjaxSource": _path + "/emailRecord/queryByPage",          
        "fnServerParams": function (aoData) {
            aoData.push(
            	{ "name": "createTime", "value": $("#fromDate").val()+","+$("#toDate").val()},
            	{"name": "user_ip" ,"value":$("#user_ip").val()},
            	{"name": "email_title" ,"value":$("#email_title").val()},
                {"name": "src_account" ,"value":$("#src_account").val()}
            );
        },
        "sServerMethod": "POST",
        "sAjaxDataProp": "dataList",
        "fnCreatedRow": function () {
            i++;
        },
        "fnPreDrawCallback": function () {
            i = 1;
        },
        "aoColumns": [
            { "sTitle": "序号", "sWidth": "2%",
                "mData": function () {
                    return i;
                }
            },    
            { "sTitle": "id", "mData": "id", "sWidth": "10%" },
            { "sTitle": "ip", "mData": "user_ip", "sWidth": "10%" },
            { "sTitle": "email标题", "mData": "email_title", "sWidth": "10%" },
            { "sTitle": "email内容", "mData": "email_content", "sWidth": "10%" },
            { "sTitle": "src内容", "mData": "src_account", "sWidth": "10%" },
            { "sTitle": "dest内容", "mData": "dest_account", "sWidth": "10%" },
            { "sTitle": "添加时间", "mData": "createTime", "sWidth": "10%"  }
        ]
    });
    

}

  //图形
function getemailRecordcount() {
var chart;
chart = new Highcharts.Chart({
    //常规图表选项设置
    chart: {
        renderTo: 'container',        //在哪个区域呈现，对应HTML中的一个元素ID
        plotBackgroundColor: null,    //绘图区的背景颜色
        plotBorderWidth: null,        //绘图区边框宽度
        plotShadow: false            //绘图区是否显示阴影            
    },
    
    //图表的主标题
    title: {
        text: '按ip点击统计量'
    },
    //当鼠标经过时的提示设置
    tooltip: {
        pointFormat: '{series.name}: <b>{point.percentage}%</b>',
        percentageDecimals: 1
    },
    //每种图表类型属性设置
    plotOptions: {
        //饼状图
        pie: {
            allowPointSelect: true,
            cursor: 'pointer',
            dataLabels: {
                enabled: true,
                color: '#000000',
                connectorColor: '#000000',
                formatter: function() {
                    //Highcharts.numberFormat(this.percentage,2)格式化数字，保留2位精度
                    return '<b>'+ this.point.name +'</b>: '+Highcharts.numberFormat(this.percentage,2) +' %';
                }
            }
        }
    },
       //图表要展现的数据
    series: [{
        type: 'pie',
        name: '份额'
    }]
});
//异步请求数据
var time= $("#fromDate").val()+","+$("#toDate").val();
var user_ip= $("#user_ip").val();
var email_title=$("#email_title").val();
var src_account=$("#src_account").val();
$.ajax({
    type:"GET",
	 	url:_path+'/emailRecord/emailRecordCount',//提供数据的Servlet
	 	data:"createTime="+time+"&user_ip="+user_ip+"&email_title="+email_title+"&src_account="+src_account+"",
    success:function(data){
        //定义一个数组
        browsers = [],
        //迭代，把异步获取的数据放到数组中
        $.each(data.classList,function(i,d){
            browsers.push([d.user_ip,d.total]);
        });
        //设置数据
        chart.series[0].setData(browsers);  
    },
    error:function(e){
        alert(e);
    }
});
}